<?php


// include 'Code.class.php';

// $config = [
// 	'lenght'=>3
// ];

// $code = new Code($config);

// $code->entry();

// var_dump(extension_loaded("GD"));
// 创建画布
$src = imageCreateTrueColor(400,200);

$color = imageColorAllocate($src,mt_rand(100,255),mt_rand(200,255),mt_rand(200,255)); 
// 选择颜色
$color = imageColorAllocate($src,255,255,255);
// 填充
imageFill($src,0,0,$color);

$color = imageColorAllocate($src,mt_rand(50,255),mt_rand(50,255),mt_rand(50,255));

// imagerectangle ($src, 0 , 0 , 200 ,100 , $color );

// for ($i=0; $i <10 ; $i++) { 
// 	$color = imageColorAllocate($src,mt_rand(50,255),mt_rand(50,255),mt_rand(50,255));

// 	imagerectangle ($src, mt_rand(0,400) ,mt_rand(0,200) , mt_rand(0,400) ,mt_rand(0,200) , $color );
// }

// imageellipse ( $src, 50 , 50 , 50 , 100 , $color);

// imagefilledellipse ( $src, 50 , 50 , 50 , 100 , $color);

// for ($i=0; $i <1000 ; $i++) { 

// 	$color = imageColorAllocate($src,mt_rand(50,255),mt_rand(50,255),mt_rand(50,255));

// 	imageline ($src, mt_rand(0,400) , mt_rand(0,200) , mt_rand(0,400) ,mt_rand(0,200), $color );
// }
// for ($i=0; $i <1000 ; $i++) {
// 	$color = imageColorAllocate($src,mt_rand(50,255),mt_rand(50,255),mt_rand(50,255));
// 	imagesetpixel ( $src, mt_rand(0,400) , mt_rand(0,200) ,  $color );
// }
$str = "zxcvbnmasdfghjklqwertyuiopASDFGHJKLZXCVBNMQWERTYUIOP1234567890";


for ($i=0; $i < 200; $i++) { 

	$color = imageColorAllocate($src,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
	$text = $str[mt_rand(0,strlen($str)-1)];
	imagettftext ( $src,14, mt_rand(-30,30) , mt_rand(0,400) , mt_rand(0,200), $color , './waterlily-script.woff.ttf', $text);
}

for ($i=0; $i < 4; $i++) { 

	$color = imageColorAllocate($src,mt_rand(50,255),mt_rand(50,255),mt_rand(50,255));

	$text = $str[mt_rand(0,strlen($str)-1)];

	$height = (200+80)/2;

	$witdh  = ((400/4)-80)/2+$i*(400/4);

	imagettftext ( $src,80, mt_rand(-15,15) , $witdh , $height, $color , './waterlily-script.woff.ttf', $text);

}

// var_dump($src);
header("Content-type: image/png");
// 输出画面
imagepng($src);
// imagepng($src,uniqid().'.png');